#ifndef LOCAL_REGRESSION_H
#define LOCAL_REGRESSION_H

#include <list>
using namespace std; 
#define	KData	std::pair<Observation, double>
#define WANT_STREAM                  // include.h will get stream fns
#define WANT_MATH                    // include.h will get math fns
#include "types.h"
//#include "newmatio.h"
//#include "newmatap.h"
//using namespace NEWMAT; 

class KNode; 
class LocalRegression
{
public:
	LocalRegression(KNode* parent, int d)
	{

		dim = d; 
		size = 0; 
		m_parent = parent; 
	}

	virtual void reset(){ size = 0;}
	virtual double addData(KData&  pt)=0; 
	virtual double addData(list<KData>& pts)=0; 
	virtual double predict(Observation o)=0; 

public:
	int dim; 
	int size;				//number of points
	KNode* m_parent;		//the corresponding cell

};



class LocalAverager: public LocalRegression
{
public: 

	void reset();
	LocalAverager(KNode* parent, int d);
	virtual double addData( KData & pt);
	double computeError();
	virtual double addData(list<KData>& pts);
	inline double kernelize(double input);
	inline double distance(Observation o1, Observation o2); 
	double predict(Observation o);

	double mean;
	//these two variables are maintained just to compute err
	double max; 
	double min; 

}; 

/*
class LinearSolver: public LocalRegression
{
public:

	LinearSolver(KNode* parent, int d)
		:LocalRegression(parent, d)
	{
		reset(d); 
	}

	void reset(int d);
	double predict(Observation o);


	double addData(list<KData>& pts);
	double addData(KData &pt); 

	void updateWeights(); 
	double getLSError(); 

	~LinearSolver(void); 

	Matrix X;				// n \times k matrix that has inputs
	ColumnVector Y;			// n \times 1 vector that has outputs
	ColumnVector W;			// k \times 1 vector that has weights



};

*/





#endif
